package pro.vet.DAO;

import java.io.Reader;
import java.util.ArrayList;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import pro.vet.beans.ProveedorBean;
import pro.vet.beans.TipoProveedorBean;
import pro.vet.beans.horario;
import pro.vet.services.Proveedor_Services;

public class Proveedor_DAO implements Proveedor_Services{

	SqlSessionFactory sqlmapper= null;{
	   	 try {
				
			
	   	 Reader reader = Resources.getResourceAsReader("ConfiguracionIbatis.xml");
	   	 
	   	 sqlmapper =new  SqlSessionFactoryBuilder().build(reader);
	   	 } catch (Exception e) {
					e.printStackTrace();
				}
	    }
	
	@Override
	public ArrayList<ProveedorBean> listarProveedor(TipoProveedorBean tipprov)
			throws Exception {
		 ArrayList<ProveedorBean> lista=null;
		 SqlSession session = sqlmapper.openSession();
			
			try {
				
				lista= (ArrayList<ProveedorBean>) session.selectList("proveedorXML.lista_proveedor",tipprov.getIdTipoProveedor());
				
			} catch (Exception e) {
				e.printStackTrace();
			}finally{ session.close();}
			System.out.println("LISTA::"+lista.get(0).getNombre());
		return lista;
		
	}
	

}
